#include "pureio.h"
#include <pthread.h>
#include<cstring>

using namespace std;
namespace ycsbc{
    thread_local static int socfd;
    static char fs[102]="ABCDEFEWRFEWRFEFG";
    thread_local char rev[1000];
    void PureIO::Init()
    {
        sockaddr_in serv_addr;
        memset(&serv_addr, 0, sizeof(serv_addr));
        serv_addr.sin_family = AF_INET;
        serv_addr.sin_addr.s_addr=inet_addr("127.0.0.1");
        serv_addr.sin_port = htons(22122);
        socfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
        connect(socfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr));
        sockets[__sync_fetch_and_add(&cnt_, 1)] = socfd;
    }

    void PureIO::io_(){
        int tmp=send(socfd, fs, 10,0);
        cout << "WR " << tmp << endl;
        tmp=recv(socfd, rev, 1000,0);
        cout << "RD " << tmp << endl;
    }
}